//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;

namespace OpenLS.Drawing.Diagram
{
    class Constraint: IOfficeXmlSerializable
    {
        ConstraintAttributes ConstraintAttributes = new ConstraintAttributes();
        ConstraintRefAttributes ConstraintRefAttributes = new ConstraintRefAttributes();
        private BooleanOperator _op;
        private double _val;
        private double _fact;
        private OfficeArtExtensionList _extLst;

        public void ReadXml(ReadContext context)
        {
            using (var c = context.Read("constr"))
            {
                ConstraintAttributes.ReadXml(c);
                ConstraintRefAttributes.ReadXml(c);
                _op = c.GetOptionalEnum("op", BooleanOperator.None);
                _val = c.GetOptionalDouble("val", 0.0);
                _fact = c.GetOptionalDouble("fact", 0.0);
                _extLst = c.ReadOptionalElement<OfficeArtExtensionList>("extLst");
            }


        }

        public void WriteXml(WriteContext context)
        {
            using (var c = context.Write("constr"))
            {
                ConstraintAttributes.WriteXml(c);
                ConstraintRefAttributes.WriteXml(c);
                c.SetOptionalEnum("op", _op, BooleanOperator.None);
                c.SetOptionalDouble("val", _val, 0.0);
                c.SetOptionalDouble("fact", _fact, 0.0);
                c.WriteOptionalElement(_extLst);
            }
        }
    }
}